#include "Method.h"
#include <iomanip>

double func(double x){
  return x - tan(x);
}

double dfunc(double x){
  double t = cos(x);
  return 1 - 1/(t*t);
}

int main(int argc, char* argv[]){
  double (*pf)(double) = &func;
  double (*pdf)(double) = &dfunc;
  Newton<double> NTSolver(50,1e-6,pf,pdf,4.5);
  double result,error = 0;
  result = NTSolver.solve();
  error = (*pf)(result);
  cout << "Near 4.5: x = " << setprecision(8) << result << ", absolute error r = " << error << endl;
  NTSolver.set_init(7.7);
  result = NTSolver.solve();
  error = (*pf)(result);
  cout << "Near 7.7: x = " << setprecision(8) << result << ", absolute error r = " << error << endl;
}
